#include "MenuSelector.h"
#include "ui_MenuSelector.h"
#include <QPainter>

MenuSelector::MenuSelector(QWidget *parent) :
	QWidget(parent),
	ui(new Ui::MenuSelector)
{
	ui->setupUi(this);

	connect(ui->btn1, SIGNAL(clicked()), SLOT(btnClicked()));
	connect(ui->btn2, SIGNAL(clicked()), SLOT(btnClicked()));
	connect(ui->btn3, SIGNAL(clicked()), SLOT(btnClicked()));
}

MenuSelector::~MenuSelector()
{
	delete ui;
}

void MenuSelector::paintEvent(QPaintEvent *)
{
	QPainter painter(this);
	QLinearGradient linearGrad(0,0,width(),0);
	linearGrad.setColorAt(0, QColor(64,64,64));
	linearGrad.setColorAt(1, QColor(130,130,130));

	painter.setBrush(QBrush(linearGrad));

	painter.drawRect(0,0,width()-1,height()-1);

	painter.setPen(QPen(QColor(172,172,172)));

	painter.drawLine(width()-2,0,width()-2,height()-1);

	painter.setBrush(Qt::NoBrush);
	painter.setPen(QPen(QColor(49,49,49)));

	painter.drawRect(0,0,width()-1,height()-1);
}

void MenuSelector::btnClicked()
{
	if(sender() == ui->btn1) emit viewChanged(0);
	if(sender() == ui->btn2) emit viewChanged(1);
	if(sender() == ui->btn3) emit viewChanged(2);
}
